Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log: switch to slog #103

Merged
merged 12 commits into from
Jan 14, 2025
Merged

log: switch to slog #103

merged 12 commits into from
Jan 14, 2025

Conversation

pulsejet
Copy link
Collaborator

Looking to take a simpler approach here similar to what Android does.

Each log message has a

  1. tag (fixed string or stringable interface)
  2. message (fixed string)
  3. args (variable)

Example usage:

// Log is *log.Logger
// y can be nil or a string, or String() interface
core.Log.Info(y, "Created multicast UDP face", "uri", uri)

Output (level=INFO)

time=2025-01-13T21:06:18.161Z level=INFO msg="Starting NDN forwarder" tag=YaNFD
time=2025-01-13T21:06:18.162Z level=INFO msg="Created unicast UDP listener" tag=YaNFD uri=udp://0.0.0.0:6363
time=2025-01-13T21:06:18.162Z level=INFO msg="Created unicast UDP listener" tag=YaNFD uri=udp://[::]:6363
time=2025-01-13T21:06:18.162Z level=INFO msg="Created Unix stream listener" tag=YaNFD uri=/run/nfd/nfd.sock
time=2025-01-13T21:06:18.162Z level=INFO msg="Starting management thread" tag=Mgmt
time=2025-01-13T21:06:18.163Z level=INFO msg=Listening tag="UnixStreamListener, unix:///run/nfd/nfd.sock"
time=2025-01-13T21:06:20.488Z level=INFO msg="Accepting new Unix stream face" tag="UnixStreamListener, unix:///run/nfd/nfd.sock" uri=fd://1
time=2025-01-13T21:06:20.490Z level=INFO msg="Set strategy" tag=StrategyChoiceMgmt name=/ndn/svs strategy="/localhost/nfd/strategy/multicast/v=1"
time=2025-01-13T21:06:20.491Z level=INFO msg="Unregistered FaceID" tag=FaceTable faceid=3
time=2025-01-13T21:06:41.628Z level=INFO msg="Accepting new Unix stream face" tag="UnixStreamListener, unix:///run/nfd/nfd.sock" uri=fd://2
time=2025-01-13T21:06:41.630Z level=INFO msg="Created route" tag=RIBMgmt name=/ndn/svs faceid=4 origin=0 cost=0 flags=1
time=2025-01-13T21:06:43.629Z level=INFO msg="Accepting new Unix stream face" tag="UnixStreamListener, unix:///run/nfd/nfd.sock" uri=fd://3
time=2025-01-13T21:06:43.630Z level=INFO msg="Created route" tag=RIBMgmt name=/ndn/svs faceid=5 origin=0 cost=0 flags=1
time=2025-01-13T21:06:51.379Z level=INFO msg="Unregistered FaceID" tag=FaceTable faceid=5
time=2025-01-13T21:06:51.848Z level=INFO msg="Unregistered FaceID" tag=FaceTable faceid=4
time=2025-01-13T21:07:40.721Z level=INFO msg="received signal - exit" tag=YaNFD signal=interrupt
time=2025-01-13T21:07:40.721Z level=INFO msg="Stopping NDN forwarder" tag=YaNFD
time=2025-01-13T21:07:40.721Z level=INFO msg="Told to quit" tag=FwThread-0
time=2025-01-13T21:07:40.721Z level=INFO msg="Told to quit" tag=FwThread-1
time=2025-01-13T21:07:40.721Z level=INFO msg="Stopping thread" tag=FwThread-1
time=2025-01-13T21:07:40.722Z level=INFO msg="Face quit, so management quitting" tag=Mgmt
time=2025-01-13T21:07:40.721Z level=INFO msg="Unregistered FaceID" tag=FaceTable faceid=1
time=2025-01-13T21:07:40.722Z level=INFO msg="Stopping thread" tag=FwThread-0

Output (level=TRACE) (WIP)

time=2025-01-13T21:11:20.102Z level=INFO msg="Starting NDN forwarder" tag=YaNFD source=github.com/named-data/ndnd/fw/executor.(*YaNFD).Start
time=2025-01-13T21:11:20.104Z level=DEBUG msg="[FaceTable] Registered FaceID=1" source=github.com/named-data/ndnd/fw/core.LogDebug
time=2025-01-13T21:11:20.104Z level=DEBUG msg="[StrategyLoader] Instantiated Strategy=/localhost/nfd/strategy/best-route/v=1 for Thread=0" source=github.com/named-data/ndnd/fw/core.LogDebug
time=2025-01-13T21:11:20.104Z level=DEBUG msg="[StrategyLoader] Instantiated Strategy=/localhost/nfd/strategy/multicast/v=1 for Thread=0" source=github.com/named-data/ndnd/fw/core.LogDebug
time=2025-01-13T21:11:20.104Z level=INFO msg="Starting management thread" tag=Mgmt source=github.com/named-data/ndnd/fw/mgmt.(*Thread).Run
time=2025-01-13T21:11:20.104Z level=DEBUG msg="[StrategyLoader] Instantiated Strategy=/localhost/nfd/strategy/best-route/v=1 for Thread=1" source=github.com/named-data/ndnd/fw/core.LogDebug
time=2025-01-13T21:11:20.104Z level=DEBUG msg="[FaceTable] Registered FaceID=2" source=github.com/named-data/ndnd/fw/core.LogDebug
time=2025-01-13T21:11:20.104Z level=DEBUG msg="[StrategyLoader] Instantiated Strategy=/localhost/nfd/strategy/multicast/v=1 for Thread=1" source=github.com/named-data/ndnd/fw/core.LogDebug
time=2025-01-13T21:11:20.105Z level=INFO msg="Created unicast UDP listener" tag=YaNFD uri=udp://0.0.0.0:6363 source=github.com/named-data/ndnd/fw/executor.(*YaNFD).Start
time=2025-01-13T21:11:20.105Z level=INFO msg="Created unicast UDP listener" tag=YaNFD uri=udp://[::]:6363 source=github.com/named-data/ndnd/fw/executor.(*YaNFD).Start
time=2025-01-13T21:11:20.105Z level=INFO msg="Created Unix stream listener" tag=YaNFD uri=/run/nfd/nfd.sock source=github.com/named-data/ndnd/fw/executor.(*YaNFD).Start

@pulsejet pulsejet requested a review from zjkmxy January 13, 2025 21:13
@pulsejet pulsejet changed the title [WIP, RFC] log: switch to slog log: switch to slog Jan 14, 2025
@zjkmxy
Copy link
Member

zjkmxy commented Jan 14, 2025

Oh this involves >100 files ...
Will review ASAP but I think I need some time.

@pulsejet
Copy link
Collaborator Author

Oh this involves >100 files ... Will review ASAP but I think I need some time.

Sorry about that, it does touch basically everything.

Any objections to the concept in general? I think the changes are largely safe.

My assumption - since NDN apps are decentralized, they don't produce the same volume / kind of logs as cloud apps. So a single "tag" field should be enough to easily filter out the logs you need. The focus, as with other PRs, is on usability.

@zjkmxy
Copy link
Member

zjkmxy commented Jan 14, 2025

My assumption - since NDN apps are decentralized, they don't produce the same volume / kind of logs as cloud apps. So a single "tag" field should be enough to easily filter out the logs you need. The focus, as with other PRs, is on usability.

I agree, but we also need filter by names. So module and name (if applicable) are mandatory .

@pulsejet
Copy link
Collaborator Author

module is tag now (function is same as before)

For name, we can directly filter using any attribute as needed. (as long as key is the same, by convention).

@zjkmxy zjkmxy merged commit 5079fca into main Jan 14, 2025
10 checks passed
@zjkmxy zjkmxy deleted the slog branch January 14, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants